#include <stdio.h>
#include <stdlib.h>

typedef int TElemSet;
typedef struct TreeNode *Position;
typedef struct TreeNode *Tree;
struct TreeNode {
    TElemSet data; /* 数据元素 */
    Tree first_child; /* 第一个子结点 */
    Tree next_sibling; /* 下一个兄弟结点 */
};

void Visit(Tree tree) {
    printf("%d\n", tree->data);
}

/* 算法5-20：后序遍历树 PostOrder(tree) */
void PostOrder(Tree tree) {
    if (tree != NULL) { /* 空树不做处理，直接返回 */
        PostOrder(tree->first_child); /* 先访问tree所有子孙结点 */
        Visit(tree); /* 接下来访问结点tree */
        PostOrder(
            tree->next_sibling); /* 最后访问tree后序的兄弟结点及其子孙 */
    }
}
/* 算法5-20 结束 */

Tree NewTreeNode() {
    Tree node_ptr;

    node_ptr = (Tree)malloc(sizeof(struct TreeNode));
    scanf("%d", &node_ptr->data);
    node_ptr->first_child = NULL;
    node_ptr->next_sibling = NULL;
    return node_ptr;
}

int main(void) {
    Tree tree, child, sibling, p;
    TElemSet x;

    tree = NewTreeNode();
    child = NewTreeNode();
    sibling = NewTreeNode();
    tree->first_child = child;
    child->next_sibling = sibling;
    sibling->next_sibling = NewTreeNode();
    PostOrder(tree);

    return 0;
}